package com.landray.oa.huanghoulin.user.service.impl;

import java.util.Date;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.landray.oa.huanghoulin.user.dao.UserDao;
import com.landray.oa.huanghoulin.user.entity.UserEntity;
import com.landray.oa.huanghoulin.user.service.UserService;


@Service
public class UserServiceImpl implements UserService {
	
	@Resource
	private UserDao dao;

	@Override
	public int login(UserEntity entity) {
		
		return dao.login(entity);
	}

	
	/**
	 * 用户注册
	 * @param entity 用户实体
	 * @return 1代表成功 0代表失败
	 */
	@Override
	public int register(UserEntity entity) {
		
		//1 先判断手机号码是否重复
		
		int ck = dao.checkPhone(entity);
		
		if(ck ==1){
			return 0;
		}
		
		//2 如果手机号码不重复 直接插入
		
		Date date = new Date();
		
		entity.setRegisterTime(date);
		
		int counter = dao.add(entity);
		return counter;
	}

}
